package product.api.fallback;

import common.server.entity.InsideRequestMessage;
import common.server.entity.InsideResponseMessage;
import common.server.entity.OutsideRequestMessage;
import common.server.entity.OutsideResponseMessage;
import common.server.fallback.ServiceFallbackFactory;
import org.springframework.stereotype.Component;
import product.api.entity.param.ProductParam;
import product.api.entity.result.ProductPojo;
import product.api.service.IProductService;

import java.util.List;

/**
 * @Title: PlatformProductServiceFallbackFactory
 * @ProjectName com-bigwavn-group
 * @Description: 后台商品服务熔断服务
 * @author: wangweitao 1749343503@qq.com
 * @date: 2019/6/4 16:11
 * @version: V1.0.0
 */
@Component
public class ProductServiceFallbackFactory extends ServiceFallbackFactory<IProductService> {

    @Override
    protected IProductService newConstant() {
        return new IProductService() {

            @Override
            public InsideResponseMessage<List<ProductPojo>> getProductList(String trace, InsideRequestMessage<ProductParam> req) {
                return (InsideResponseMessage<List<ProductPojo>>) buildInsideFallbackResp(req);
            }

            @Override
            public InsideResponseMessage<ProductPojo> getProductCount(String trace, InsideRequestMessage<ProductParam> req) {
                return (InsideResponseMessage<ProductPojo>) buildInsideFallbackResp(req);
            }

            @Override
            public OutsideResponseMessage<ProductPojo> getProductLists(String trace, OutsideRequestMessage<ProductParam> req) {
                return (OutsideResponseMessage<ProductPojo>)buildOutsideFallbackResp(req);
            }
        };
    }
}
